package demo;

import java.util.Scanner;

public class WormTest {
	public static void main(String[] args){
		WormPanel wormPanel = new WormPanel();
		Worm worm = wormPanel.getWorm();  // XXXXX
		Scanner scanner = new Scanner(System.in);
		while(true){
			wormPanel.print();  //XXXXXX
			String str = scanner.nextLine();
			if(str.equalsIgnoreCase("w")){
				worm.step(worm.UP);
			}
			else if(str.equalsIgnoreCase("s")){
				worm.step(worm.DOWN);
			}			
			else if(str.equalsIgnoreCase("a")){
				worm.step(worm.LEFT);
			}
			else if(str.equalsIgnoreCase("d")){
				worm.step(worm.RIGHT);
			}
			else if(str.equalsIgnoreCase("q")){
				break;
			}
			else{
				worm.step();
			}
		}
	}
}
